<?php

class Status extends MY_Controller
{
	function Status() 
	{
		parent::MY_Controller();

		header('Expires: Thu, 01-Jan-70 00:00:01 GMT');
		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
		header('Cache-Control: no-store, no-cache, must-revalidate');
		header('Pragma: no-cache');

		# add custom css file for user controller
		$this->data['header_data']['css'][] = '/css/account.css';
	}
	
	public function code($status = 0)
	{		
		switch($status)
		{
			case GENERAL_ERROR:
				$this->data['header_data']['page_title'] = 'turbotask.me - ' . lang('error');
				$viewdata['title'] = lang('error');
				$viewdata['img'] = '/img/error.png';
				$viewdata['message'] = lang('general_error') . $this->config->item('support_email');
				break;
				
			case OK_RECOVERY_KEY_SENT:
				$this->lang->load('account');
				$this->data['header_data']['page_title'] = 'turbotask.me - ' . lang('recover_password');
				$viewdata['title'] = lang('recover_password');
				$viewdata['img'] = '/img/letter.png';
				$viewdata['message'] = lang('recover_key_sent');			
				break;
			
			case OK_CHANGE_PASS:
				$this->lang->load('account');
				$this->data['header_data']['page_title'] = 'turbotask.me - ' . lang('recover_password');
				$viewdata['title'] = lang('recover_password');
				$viewdata['img'] = '/img/key.png';
				$viewdata['message'] = lang('newpass_ok');
				break;
			case ERR_CHANGE_PASS:
				$this->lang->load('account');
				$this->data['header_data']['page_title'] = 'turbotask.me - ' . lang('recover_password');
				$viewdata['title'] = lang('recover_password');
				$viewdata['img'] = '/img/error.png';
				$viewdata['message'] = lang('newpass_err') . $this->config->item('support_email');
				break;
			case OK_CHANGE_EMAIL:
				$this->lang->load('account');
				$this->data['header_data']['page_title'] = 'turbotask.me - ' . lang('change_email');
				$viewdata['title'] = lang('change_email');
				$viewdata['img'] = '/img/email.png';
				$viewdata['message'] = lang('change_email_ok') . '<strong>' . $this->session->userdata('email') . '</strong>';
				break;	
				
			case ERR_TOO_MANY_RECOVERY_ATTEMPTS:
				$this->lang->load('account');
				$this->data['header_data']['page_title'] = 'turbotask.me - ' . lang('recover_password');
				$viewdata['title'] = lang('recover_password');
				$viewdata['img'] = '/img/anonymous.png';
				$viewdata['message'] = lang('newpass_too_many_retries');
				break;	
				
			default:
				redirect( site_url('/'), 'location');
				break;
		}

		$this->data['content'] = $this->load->view('account/message', $viewdata, true);
		$this->load->view('global/master-view', $this->data);
	}	
}
